package com.acwing.partition44;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/5/22 9:31
 */
public class AC4330非传递骰子 {

    private static int[] a = new int[4], b = new int[4], c = new int[4];

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        int t = nextInt();
        while (t-- > 0) {
            for (int i = 0; i < 4; i++) a[i] = nextInt();
            for (int i = 0; i < 4; i++) b[i] = nextInt();
            if (check(a, b)) f(a, b);
            else if (check(b, a)) f(b, a);
            else writer.println("no");
        }
        writer.flush();
    }

    private static void f(int[] a, int[] b) {
        for (int i = 1; i <= 10; i++) {
            c[0] = i;
            for (int j = 1; j <= 10; j++) {
                c[1] = j;
                for (int x = 1; x <= 10; x++) {
                    c[2] = x;
                    for (int y = 1; y <= 10; y++) {
                        c[3] = y;
                        if (check(c, a) && check(b, c)) {
                            writer.println("yes");
                            writer.flush();
                            return;
                        }
                    }
                }
            }
        }
        writer.println("no");
    }

    private static boolean check(int[] a, int[] b) {
        int win = 0, lose = 0;
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                if (a[i] > b[j]) win++;
                else if (a[i] < b[j]) lose++;
            }
        }
        return win > lose;
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }
}
